import java.io.*;
public class LineNumberDemo {
	public static void main(String[] args) {
		try{
			String fName="D:\\myfile.txt";
			FileInputStream fis=new FileInputStream(fName);
			LineNumberInputStream lnis=new LineNumberInputStream(fis);
			DataInputStream dis=new DataInputStream(lnis);
			String line;
			while((line=dis.readLine())!=null){
				System.out.println(lnis.getLineNumber()+":"+line);
			}
			dis.close();
			lnis.close();
			fis.close();			
		}catch(FileNotFoundException ex){
			ex.printStackTrace();
		}catch(IOException ex){
			ex.printStackTrace();
		}
	}
}
